'use strict';
const { Controller } = require('egg');
class HomeController extends Controller {
  // 列表数据
  async index() {
    const { ctx } = this;
    const {id} = ctx.query
    const results = await this.app.mysql.select('listss',{id:id});
    ctx.body = {
      code: 200,
      list: results
    };  
  };
  async detail() {
    const { ctx } = this;
    const {id} = ctx.query
    const results = await this.app.mysql.get('listss',{id:id});
    ctx.body = {
      code: 200,
      list: results
    };
  };
  // 首页数据
  async home() {
    const { ctx } = this;
    const results = await this.app.mysql.select('car');
    ctx.body = {
      code: 200,
      list: results
    };
  };
// 首页数据
async add() {
  const { ctx } = this;
  const {url,name,price,title} = ctx.request.body
  const results = await this.app.mysql.insert('car',{url,name,price,title});
  ctx.body = {
    code: 200,
    list: results
  };
};
}
module.exports = HomeController;